home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11263 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.6 KB  |  70 lines

  1. Newsgroups: comp.lang.c
  2. Path: new-news.sprintlink.net!news1!ind-004-236-171
  3. From: dlmiller@iquest.net (Doug Miller)
  4. Subject: Re: String Upper/Lower--void main an error?
  5. X-Nntp-Posting-Host: ind-004-236-171.iquest.net
  6. Message-ID: <DooA9I.HI4@iquest.net>
  7. Sender: news@iquest.net (News Admin)
  8. Organization: IQuest Network Services
  9. X-Newsreader: News Xpress Version 1.0 Beta #2.1
  10. References: <4ifra6$52i@scipio.cyberstore.ca> <DoFA24.AL7@iquest.net> <4ii1nh$bng@castle.nando.net> <4ini70$8j@vodka.intele.net>
  11. Date: Fri, 22 Mar 1996 14:17:28 GMT
  12.  
  13. cjmorgan@intele.net (Jason V. Morgan) wrote:
  14. +Xref: news1 comp.lang.c:71136
  15. +Path: news1!news.sprintlink.net!new-news.sprintlink.net!news.sprintlink.net!psgrain!news.uoregon.edu!xmission!inteleNET!usenet
  16. +From: cjmorgan@intele.net (Jason V. Morgan)
  17. +Newsgroups: comp.lang.c
  18. +Subject: Re: String Upper/Lower--void main an error?
  19. +Date: 20 Mar 1996 00:06:56 GMT
  20. +Organization: inteleNET Internet Services
  21. +Lines: 37
  22. +Message-ID: <4ini70$8j@vodka.intele.net>
  23. +References: <4ifra6$52i@scipio.cyberstore.ca> <DoFA24.AL7@iquest.net> <4ii1nh$bng@castle.nando.net>
  24. +NNTP-Posting-Host: 206.29.210.151
  25. +Mime-Version: 1.0
  26. +Content-Type: Text/Plain; charset=US-ASCII
  27. +X-Newsreader: WinVN 0.99.7
  28. +
  29. +>>void main (void) {
  30. +>
  31. +>Oh, please!  Read the FAQ to avoid posting crap like this.
  32. +>
  33. +>>char    test[] = "aBcDeFgHiJkLmNoPqRsTuVwXyZ";
  34. +>>char    *p;
  35. +>>
  36. +>>printf ("%s\n", &test);
  37. +>
  38. +>&test ???  How about just test?
  39. +>
  40. +>>for (p = test; *p; *p++)
  41. +>
  42. +>And what do you think you are accomplishing with *p++ that p++ or ++p
  43. +>wouldn't do???
  44. +>
  45. +>>    if (isalpha(*p)) *p ^= 0x20;  /* for ascii machines e.g. PC; use 0x40 for
  46. +ebcdic machines e.g. IBM mainframe */
  47. +>
  48. +>isalpha() has not been declared.  It takes an int and *p may be a signed
  49. +>char, how about *(unsigned char *)p.  Also, your code is toggling between
  50. +>upper and lower case.
  51.  
  52. OF COURSE the code toggles between upper and lower case -- that's what he asked for.
  53.  
  54. +
  55. +>>printf ("%s\n", &test);
  56. +>
  57. +>There you go again with this &test thingy.  Finally, you'll want a
  58. +>"return 0;" after you've fixed the "void main" error.
  59. +
  60. +I don't thing that void main is really considered to be an error.  Return
  61. +values are only really necessary if they're going to mean anything.  It is
  62. +compilable (maybe I'm wrong and it's not portable).  At least it was declared
  63. +void so it didn't default to an int.  You might as well say that it's an error
  64. +because argc, argv, and env weren't passed (to be honest, I'm not sure if env
  65. +is actually standard, I got it from the programmer's reference, not the
  66. +standard).
  67. +                --Jason V. Morgan
  68. +
  69.  
  70.